﻿namespace DesignModeConsole.行为型.职责链模式.处理不返回;

/// <summary>
/// 数组的形式
/// </summary>
public interface IHandler4
{
    bool Handler();
}

public class Handler4A : IHandler4
{
    public bool Handler()
    {
        var handled = false;
        // 业务逻辑计算
        Console.WriteLine("我是Handler4A");
        return handled;
    }
}

public class Handler4B : IHandler4
{
    public bool Handler()
    {
        var handled = false;
        // 业务逻辑计算
        Console.WriteLine("我是Handler4B");
        return handled;
    }
}

public class HandlerChain4
{
    private readonly List<IHandler4> _handler4 = new List<IHandler4>();

    public void AddHandler(IHandler4 handler)
    {
        _handler4.Add(handler);
    }

    public void Handle()
    {
        foreach (var handler in _handler4)
        {
            handler.Handler();
        }
    }
}